<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
	<title>TravelDream Home</title>
	<h:outputStylesheet library="TdTheme" name="css/style.css"/> 	
</h:head>
<h:body>	
	<h:form>      
	    <p:menubar>
	    	<p:menuitem value="Homepage" icon="ui-icon-contact" url="home.xhtml?faces-redirect=true"/> 
	         
	        <f:facet name="options">
	        	<p:outputLabel value="Benvenuto, #{utenteManagedBean.nome}" style="margin-right:10px"/>  
	            <p:commandButton value="Modifica Profilo" icon="ui-icon-contact" action="modifica_utente.xhtml?faces-redirect=true"/>
	            <p:commandButton value="Logout" icon="ui-icon-extlink" action="#{loginManagedBean.logout()}"/>  
	        </f:facet>  
	    </p:menubar>  
  	</h:form> 
	<h:panelGrid columns="1" styleClass="userTopBar">
		<p:panel>
			<h:form id="search_form">
				<h:panelGrid columns = "5">
					<h:outputLabel value="Data Partenza: Da: " />
					<p:calendar value="#{searchPacchettoManagedBean.dataFrom}" id="fromD" navigator="true" mindate="#{searchPacchettoManagedBean.getTodayDate()}" >
						<p:ajax event="dateSelect" update="toD"/>
					</p:calendar>
					<h:outputLabel value="A: " />
					<p:calendar id="toD" value="#{searchPacchettoManagedBean.dataTo}" navigator="true" mindate="#{searchPacchettoManagedBean.dataFrom}">
						<f:attribute name="startDate" value="#{searchPacchettoManagedBean.dataFrom}"/>
						<f:validator validatorId="dateRangeValidator"/>
					</p:calendar>
					<br/>
					<h:outputLabel value="Destinazione:" />
					<p:inputText value="#{searchPacchettoManagedBean.destinazione}" id="destInput"/>
					<p:commandButton value="Cerca" action="#{searchPacchettoManagedBean.searchPP()}" style="margin-left:100%;"/> 
				</h:panelGrid>
				<p:messages showDetail="true" autoUpdate="true"/>
				<p:dataTable id="searchOutput" var="p" value="#{searchPacchettoManagedBean.searchResult}" rendered="#{searchPacchettoManagedBean.searchResult != null and searchPacchettoManagedBean.searchResult.size() != 0}">
  						<p:column headerText="Immagine">
                    		<img style="width:100px" src="../resources/TdTheme/img/hotel.png"/>
                		</p:column>
						
						<p:column headerText="Nome">
		                    <h:outputText value="#{p.nome}"/>
		                </p:column>
		                
		                <p:column headerText="Destinazione">
		                    <h:outputText value="#{p.destinazione_pacchetto}"/>
		                </p:column>
		                
		                <p:column headerText="Prezzo">
		                	<h:outputText value="#{p.getPrezzoBase()} euro"/>
		                </p:column>
                		
		                <p:column>
		                	<p:commandButton value="Dettagli" action="#{dettagliPPManagedBean.parametriPP(p)}"/>
		                </p:column>
                </p:dataTable>	
			</h:form>
		</p:panel>
	</h:panelGrid>
</h:body>
</html>